Number Base Converter

Convert binary, octal, decimal and hexadecimal all at once

What this tool does

Enter a number and choose which base it is in (2, 8, 10 or 16), and this number base converter shows the same value in binary, octal, decimal and hexadecimal at once. It opens with decimal 255, so you immediately see binary 11111111, octal 377 and hex FF. Use it to read hex colour codes or bit values in programming, to check base-conversion answers for computer science homework, or to interpret memory addresses and octal permission values.

How it is calculated

It first checks that every character is valid for the chosen base: 0 and 1 for binary, 0-7 for octal, 0-9 for decimal, and 0-9 plus A-F (lowercase works) for hex. If valid, the value is read as an integer and rewritten in all four bases, with hex letters shown in capitals. The manual method is the same idea. To convert to decimal, multiply each digit by the matching power of the base and add: binary 1011 is 1x8 + 0x4 + 1x2 + 1x1 = 11. To convert from decimal, divide repeatedly by the target base and read the remainders backwards: 11 is B in hex, 13 in octal and 1011 in binary. Results update as you type or change the base.

  • Type a number (e.g. 255, 1011, FF)
  • Choose that number's base; the default is decimal
  • Binary, octal, decimal and hex results appear together, with the input base highlighted
  • Invalid characters trigger a message saying the base cannot use them
  • Numbers that are too large show a message instead of a result

Things to know

  • Two hex digits are exactly one byte (0-255). In the colour #FF8800, entering FF, 88 and 00 gives red 255, green 136 and blue 0.
  • Binary to octal: group three digits from the right; binary to hex: group four. That is why 1111 1111 is FF with no arithmetic.
  • Leave out code prefixes such as 0x, 0b or 0o; the x or b may be flagged as an invalid character.
  • Minus signs, decimal points and spaces are not accepted. Only whole numbers from 0 upward are converted.
  • The largest convertible value is 9,007,199,254,740,991 in decimal (2^53 - 1). Above that, a message replaces the result so no digits come out wrong.
  • A Linux file permission such as 755 is octal. Entered as octal it shows binary 111101101, the read, write and execute bits for user, group and others.

Frequently asked questions

Why is hex FF equal to 255?

F is 15 and there are two digits, so 15 x 16 + 15 = 255. It is the largest value one byte (8 bits) can hold.

Why do computers use binary?

On and off are the two states an electrical circuit can tell apart most reliably. Hex is a human-friendly shorthand that packs four binary digits into one.

Can it convert negative numbers or fractions?

No. It handles whole numbers from 0 upward only. Two's complement for negatives and fractional base conversion need separate calculation.

What happens with a very large number?

Above about 9 quadrillion in decimal (2^53 - 1), a message says it cannot be converted exactly and no result is shown, so you never get a wrong value.

← na.to home